﻿using JustMetClient.Models.InfoModels;
using Azylee.Core.AppUtils;
using Azylee.Core.IOUtils.DirUtils;
using Azylee.Core.WindowsUtils.InfoUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JustMetClient.Utils.InfoUtils
{
    public static class SystemInfoTool
    {
        /// <summary>
        /// 获取系统信息
        /// </summary>
        public static SystemInfoModel Get()
        {
            SystemInfoModel info = new SystemInfoModel();
            //设置计算机名
            info.MachineName = Environment.MachineName;
            //操作系统
            var system = ComputerInfoTool.OsInfo();
            if (system != null) info.System = system.Item1;
            //系统版本
            info.Version = ComputerInfoTool.OSVersion();
            //64位
            info.Is64 = ComputerInfoTool.Is64BitOperatingSystem();
            //安装日期
            if (system != null) info.InstallDate = system.Item3;
            //当前用户
            info.User = ComputerInfoTool.UserName();
            //计算机域名
            info.Domain = ComputerInfoTool.UserDomainName();
            //程序运行权限
            info.Permission = PermissionTool.IsAdmin();
            //总内存
            info.RAMSize = (long)ComputerInfoTool.TotalPhysicalMemory();
            //可用物理内存
            info.RAMAvailSize = (long)ComputerInfoTool.AvailablePhysicalMemory();
            //系统盘总量
            info.SysDriveSize = ComputerInfoTool.GetSystemDriveTotalSize();
            //可用系统盘容量
            info.SysDriveAvailSize = ComputerInfoTool.GetSystemDriveAvailableSize();
            //统计本机所有账号
            info.Users = string.Join(",", ComputerInfoTool.UserNames());
            return info;
        }
    }
}
